/*
 * @Author: Superficial
 * @Date: 2021-07-23 16:25:23
 * @LastEditTime: 2022-06-01 00:57:09
 * @Description: 错误生成器
 */
import { UnauthorizedException } from '@nestjs/common'
import { ResponseMessage } from '@app/interfaces/response.interface'
import * as TEXT from '@app/constants/text.constant'

/**
 * @class HttpUnauthorizedError
 * @classdesc 401 -> 未授权/权限验证失败
 * @example new HttpUnauthorizedError('unauthorized')
 * @example new HttpUnauthorizedError('error message', new Error())
 */
export class HttpUnauthorizedError extends UnauthorizedException {
  constructor(message?: ResponseMessage, error?: any) {
    super(message || TEXT.HTTP_UNAUTHORIZED_TEXT_DEFAULT, error)
  }
}
